//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.lyq.bean.mySql;

import com.lyq.bean.Student;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

public class SeekAllS_Sql {
    public SeekAllS_Sql() {
    }

    public List<Student> seekAllS_Sql(List<Student> list) {
        (new MysqlLinking()).getLink();
        Connection conn = MysqlLinking.conn;
        if (conn != null) {
            try {
                String sql = "select * from student ";
                PreparedStatement ps = conn.prepareStatement(sql);
                ResultSet rs = ps.executeQuery();

                while(rs.next()) {
                    Student s = new Student();
                    s.setNo(rs.getString("S_No"));
                    s.setName(rs.getString("S_Name"));
                    s.setSex(rs.getString("S_Sex"));
                    s.setAge(rs.getString("S_Age"));
                    s.setCollage(rs.getString("S_Collage"));
                    s.setDepartment(rs.getString("S_Department"));
                    s.setCampus(rs.getString("S_Campus"));
                    s.setMajorId( rs.getInt("major_id"));
                    s.setYearId( rs.getInt("year_id"));
                    // 获取GPA字段
                    s.setGpa(rs.getDouble("gpa"));
                    list.add(s);
                }

                rs.close();
                ps.close();
            } catch (Exception var7) {
                Exception e = var7;
                e.printStackTrace();
            }
        } else {
            System.out.println("数据库连接错误！");
        }

        return list;
    }
}